Ext.: http://blog.chinaunix.net/uid-26896647-id-3433968.htmlQuestion Description: If there are special characters such as ' & ', ' _ ', '% ' on a field in a table, and we have to use these special characters in the Where condition?1. Create a table
SQL Server: SQL like wildcard special usage: Escape
%: Match zero or multiple arbitrary characters; _: match any single character; []: match a range; [^]: exclude a range
symbol
meaning
like '5 [%] '
%: matches 0 or more arbitrary characters; _: matches any single character; []: Matches a range; [^]: excludes a range;-: hyphenSymbol meaningLike ' 5[%] ' 5%Like ' [_]n ' _nLike ' [A-CDF] ' A, B, C, D, or FLike ' [-ACDF] '-, A, C, D, or FLike ' [[]
One, wildcard charactersWildcard Description Example %: Matches any string that contains 0 or more characters。 The WHERE title like '%computer% ' will find all titles that contain the word computer anywhere in the title._ (Underscore): Match any
One, wildcard charactersWildcard Description Example%: Matches any string that contains 0 or more characters。 The WHERE title like '%computer% ' will find all titles that contain the word computer anywhere in the title._ (Underline): Matchany single
If you want to query in SQL like with an underscore ' _ ' or a '% ' equivalent of a record, write directly to like ' xxx_xx ', then ' _ ' will be treated as a wildcard character like. The escape clause is provided in SQL to handle this situation,
It is well known that the LIKE operator in T-SQL uses a% symbol to denote wildcards. Most of the time, you may need to query for data that contains a percentage, such as Querying the field coupon contains 5% of the data. So how do you use a like
Search for fields
Search for fields
Find '%' in the field, which involves the escape characters of Oracle. The following is a summary:
SQL> select * from test;
TEST--------------------Sdd_kkD 'dDfsfsaDffa % asfs123451% 23451% 543212% 54321%
Use ESCAPE to define escape characters in SQL.
Use ESCAPE to define ESCAPE characters
When the LIKE keyword is used for fuzzy search, "%", "_", and "[]" appear separately, and are considered as wildcards. To check whether there are percent (%),
Tagged with: MySQL like escape percent semicolon wildcardWildcard characters in the like statement for MySQL: percent, underscore, and escape% represent any number of characters in SQL code Http://blog.csdn.net/yc7369/select * from user where
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.